<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://www.butternutskipatrol.com">
	<html><title></title></html>
	<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<html>
			<body bgcolor="#ffffff">
			<table border="0" style="font-family: Verdana">
				<tr><td colspan="6" align="center">
				<span style="font-weight: bold; font-size: 14pt">Butternut Ski Patrol</span>
				</td></tr>
				<tr><td colspan="6" align="center">
				<span style="font-weight: bold; font-size: 12pt">2012-2013 Service Day Report</span>
				</td></tr>
				<tr><td colspan="6" align="center">
				<span style="font-weight: font-size: 6px">as of
					<xsl:value-of select="a:Data/@ServiceDayRecord"/>
				</span>
				</td></tr>
					<tr bgcolor="#999999">
						<th align="left">Patroller</th>
						<th style="width=50px;">Days</th>
						<th style="width=50px; background-color=#FFFFFF"></th>
						<th align="left">Patroller</th>
						<th style="width=50px;">Days</th>
					</tr>
					<!-- go through each row -->
					<xsl:for-each select="a:Data/a:Roster/a:Person">
					<xsl:sort select="@LastName"/>
						
					<!-- determine what column to write -->		
					<xsl:if test="position() mod 2 = 1">
					<!-- close the current row after the second person is written and keep it tidy -->		
						<xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
						<xsl:text disable-output-escaping="yes">&#10;</xsl:text>
					<!-- create a new row for as long as we are not on the last person -->
						<xsl:if test="position() != last()">
							<xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
						</xsl:if>
					<!-- need to create 1 last row to close out the table cleanly -->	
						<xsl:if test="position() = last()">
							<xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
						</xsl:if>
					</xsl:if>
					<!-- write the cells for the columns -->
						<td>
							<xsl:value-of select="@FirstName"/><xsl:text disable-output-escaping="yes"> </xsl:text><xsl:value-of select="@LastName"/> 
						</td>
						<td align="center">
							<xsl:value-of select="count(a:ServiceDay)"/>
						</td>
						<td></td>
					<!-- need to close the last row to close out the table cleanly -->
						<xsl:if test="position() = last()">
							<xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
						</xsl:if>
					</xsl:for-each>

				</table>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
